<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <link type="text/css" rel="stylesheet" th:href="@{/css/all.css}"/>
    <link type="text/css" rel="stylesheet" th:href="@{/plugin/zTree_v3-master/css/metroStyle/metroStyle.css}"/>
    <link type="text/css" rel="stylesheet" th:href="@{/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css}"/>

    <link type="text/css" rel="stylesheet" th:href="@{/plugin/jHsDate/jHsDate.css}"/>
    <!--
    <script language="JavaScript" th:src="@{/js/all.js}" src="js/all.js"></script>
-->

    <script language='JavaScript' th:src='@{/plugin/jQuery/jQuery-2.2.0.min.js}'></script>
    <script language='JavaScript' th:src="@{/ajax/layer/layer.min.js}"></script>
    <script language='javascript' th:src='@{/js/constant.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/jQuery/jquery.mousewheel.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/jquery-easyui-1.5.1/jquery.easyui.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/bootstrap/js/bootstrap.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/bootstrap-table/bootstrap-table.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/adminLTE/js/app.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/lobibox/dist/js/lobibox.js}'></script>
    <script language='JavaScript' th:src='@{/js/network.js}'></script>
    <script language='JavaScript' th:src='@{/js/common.js}'></script>
    <script language='JavaScript' th:src='@{/js/public.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/bootstrap-datetimepicker/js/moment-with-locales.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/iCheck/icheck.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/zTree_v3-master/js/jquery.ztree.core.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/zTree_v3-master/js/jquery.ztree.excheck.min.js}'></script>
    <script language='JavaScript' th:src='@{/plugin/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js}'></script>

    <script language='JavaScript' th:src='@{/plugin/jHsDate/jHsDate.js}'></script>


    <style type="text/css">
        .form-group{
            margin-top: 5px;
            margin-bottom: 5px;
        }
        #trigger3 span:last-child tt{ color:#fff}
        #trigger3 span tt{ font-size:14px; line-height:24px; color:#000}
        .clear {
            clear: both
        }
        .RadioStyle input {
            display: none
        }
        .RadioStyle label {
            border: 1px solid #00a4ff;
            padding: 2px 10px 2px 5px;
            line-height: 25px;
            min-width: 80px;
            text-align: center;
            float: left;
            margin: 2px;
            border-radius: 4px
        }
        .RadioStyle input:checked + label {
            background: url(../img/ico_checkon.svg) no-repeat right bottom;
            background-size: 21px 21px;
            color: #00a4ff
        }
    </style>
</head>
<body class="body-contrainner fadeInUp">
<div class="box box-info">
    <div class="box-header with-border">
        <form id="form-search" class="form-inline has-info">
            <div class="form-group">
                <label class="control-label">任务名称</label>
                <input type="text" id="job_name" name="job_name@@like" class="form-control" placeholder="请输入任务名称">
            </div>
            <div class="form-group">
                <label class="control-label">任务方法</label>
                <input type="text" id="method_name" name="method_name@@like" class="form-control" placeholder="请输入任务方法">
            </div>
            <div class="form-group">
                <label class="control-label">创建人</label>
                <input type="text" id="create_by" name="create_by@@like" class="form-control" placeholder="请输入创建人名称">
            </div>
        </form>
        <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
        </div>
    </div>
    <div class="box-body" style="padding-top: 0px;">
        <div id="tool-bar">
            <button id="btn-search" type="button" class="btn btn-info"><i class="fa fa-search margin-r-5"></i>查询</button>
            <button id="btn-add" type="button" class="btn btn-default"><i class="fa fa-plus margin-r-5"></i>新增</button>
            <button id="btn-edt" type="button" class="btn btn-default"><i class="fa fa-edit margin-r-5"></i>编辑</button>
            <button id="btn-del" type="button" class="btn btn-default"><i class="fa fa-remove margin-r-5"></i>删除</button>
            <button id="btn-start" type="button" class="btn btn-primary"><i class="fa fa-play margin-r-5"></i>启用</button>
            <button id="btn-pause" type="button" class="btn btn-danger"><i class="fa fa-pause margin-r-5"></i>暂停</button>
            <button id="btn-startNow" type="button" class="btn btn-primary"><i class="fa fa-play margin-r-5"></i>立即执行一次</button>
            <button id="btn-export" type="button" class="btn btn-default"><i class="fa fa-download margin-r-5"></i>导出</button>
        </div>
        <table id="data-table" class="table table-bordered" data-striped="true" data-pagination="true" data-search="false"
               data-search-on-enter-key="true" data-show-columns="true" data-show-refresh="true"
               data-show-toggle="true" 	data-show-pagination-switch="true" data-id-field="id"
               data-unique-id="id" data-click-to-select="true" data-side-Pagination="server"
               data-cache="false" data-method="get" data-toolbar="#tool-bar" data-query-params="getParam">
            <thead>
            <tr id="tab">

            </tr>
            </thead>
        </table>
    </div>
</div>

<div id="input-modal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content" style="min-width:600px;max-width: 700px;  width: 100%;" >
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title text-info">填写定时任务信息</h4>
            </div>
            <div class="modal-body">
                <form id="form-input" class="form-horizontal has-info form-validate">
                    <div class="form-group">
                        <label class="control-label col-md-3 required1">任务类名</label>
                        <div class="col-md-8">
                            <select class="form-control" name="jobName" id="job_nameS">
                                <!--<option value="">****顶级菜单****</option>-->
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 required1">有无参数</label>
                        <div class="col-md-8">
                            <select class="form-control" name="jobGroup" id="job_groupS">
                                <option value="">---请选择---</option>
                                <option value="1">有参数</option>
                                <option value="2">无参数</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 required1">方法名称</label>
                        <div class="col-md-8">
                            <select class="form-control" name="methodName" id="method_nameS">
                                <!--<option value="">****顶级菜单****</option>-->
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3">方法参数</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="methodParams" placeholder="请输入方法参数" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 required1">执行方式</label>
                        <div class="col-md-8">
                            <div class="RadioStyle">
                                <div class="Block PaddingL">
                                    <input type="radio" name="Storage" id="model1" checked >
                                    <label for="model1" id="model1label" >每天执行</label>
                                    <input type="radio" name="Storage" id="model4"  >
                                    <label for="model4" id="model4label" >间隔执行</label>
<!--                                    <input type="radio" name="Storage" id="model5"  >
                                    <label for="model4" id="model5label" >间隔执行(分)</label>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 required1" id="labelMessage">每天</label>
                        <div class="col-md-4">
                           <input type="input" class="form-control" id="time" style="text-align: center;"  name="jHsDateInput" value="点我选择时间"/>
                        </div>
                            <label class="control-label col-md-4" style="text-align: left;padding-left: 0;">执行一次</label>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 required1">执行失败策略</label>
                        <div class="col-md-8">
                            <select class="form-control" name="misfirePolicy" id="misfirePolicyS">
                                <option value="">---请选择---</option>
                                <option value="1">立即执行</option>
                                <option value="2">执行一次</option>
                                <option value="3">放弃执行</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3">备注</label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" name="remark" placeholder="请输入备注" >
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button id="btn-cancel" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="btn-save" type="button" class="btn btn-info">保存</button>
            </div>
        </div>
    </div>
</div>



<div id="input-modal2" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content" style="min-width:300px;max-width: 400px;  width: 70%;" >
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <center><span  style="font-size:20px;">导出字段选择</span></center>
            </div>

            <div class="modal-body" id="messageBody" style="height:340px; overflow:scroll;text-align: center;">
                <div class="btn-group" id="checks" data-toggle="buttons" style="text-align: center;">


                </div>
            </div>
            <div class="modal-footer">
                <center>
                <button id="btn-selectAll" type="button" class="btn btn-default" >反选</button>
                <button id="btn-cancel2" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="btn-save2" type="button" class="btn btn-info">保存</button>
                </center>
            </div>
        </div>
    </div>
</div>



<script language="JavaScript">
    //========定时任务类名与方法联动模块
    var ScheMesage={};
    ajax.postData(publicData.urls.system.getScheTasks, {}, function (data) {
        ScheMesage=data;
        var ClassHtml='<option value="">---请选择---</option>';
        var MethodHtml='<option value="">---请选择---</option>';
        for(var i=0;i<ScheMesage.length;i++){
            ClassHtml+='<option value="'+ScheMesage[i].ClassName[0]+'">'+ScheMesage[i].ClassName+'</option>'
        }
        $("#method_nameS").html(MethodHtml)
        $("#job_nameS").html(ClassHtml)
    });
    $("#job_nameS").change(function () {
        var MethodHtml='<option value="">---请选择---</option>';
        var job_nameValue=$("#job_nameS").val();
        var job_groupValue=$("#job_groupS").val();
        for(var i=0;i<ScheMesage.length;i++){
            if(ScheMesage[i].ClassName[0]!=job_nameValue){
               continue;
            }
            var noParams=ScheMesage[i].NoParams;
            var Params=ScheMesage[i].Params;
            if(job_groupValue=='1'){
                for(var j=0;j<Params.length;j++) {
                    MethodHtml+='<option value="'+Params[j]+'">'+Params[j]+'</option>'
                }
            }else if(job_groupValue=='2'){
                for(var j=0;j<noParams.length;j++) {
                    MethodHtml+='<option value="'+noParams[j]+'">'+noParams[j]+'</option>'
                }
            }else{
                for(var j=0;j<Params.length;j++) {
                    MethodHtml+='<option value="'+Params[j]+'">'+Params[j]+'</option>'
                }
                for(var j=0;j<noParams.length;j++) {
                    MethodHtml+='<option value="'+noParams[j]+'">'+noParams[j]+'</option>'
                }
            }
        }
        $("#method_nameS").html(MethodHtml)
    });
    $("#job_groupS").change(function () {
        var MethodHtml='<option value="">---请选择---</option>';
        var job_nameValue=$("#job_nameS").val();
        var job_groupValue=$("#job_groupS").val();
        for(var i=0;i<ScheMesage.length;i++){
            if(ScheMesage[i].ClassName[0]!=job_nameValue){
                continue;
            }
            var noParams=ScheMesage[i].NoParams;
            var Params=ScheMesage[i].Params;
            if(job_groupValue=='1'){
                for(var j=0;j<Params.length;j++) {
                    MethodHtml+='<option value="'+Params[j]+'">'+Params[j]+'</option>'
                }
            }else if(job_groupValue=='2'){
                for(var j=0;j<noParams.length;j++) {
                    MethodHtml+='<option value="'+noParams[j]+'">'+noParams[j]+'</option>'
                }
            }else{
                for(var j=0;j<Params.length;j++) {
                    MethodHtml+='<option value="'+Params[j]+'">'+Params[j]+'</option>'
                }
                for(var j=0;j<noParams.length;j++) {
                    MethodHtml+='<option value="'+noParams[j]+'">'+noParams[j]+'</option>'
                }
            }
        }
        $("#method_nameS").html(MethodHtml)
    });
    //========定时任务类名与方法联动模块结束



    var myTableName='sys_job';

    var operateFormatterStatus = function(value,row,index) {//赋予的参数
        if (value=="1") {
            return [
                '<span style="text-align: center;display:block;"><label class="label label-info label-block" style="cursor:pointer">立即执行</label></span>', ]
                .join('');
        }else if(value=="2"){
            return [
                '<span style="text-align: center;display:block;"><label class="label label-primary label-block" style="cursor:pointer">执行一次</label></span>', ]
                .join('');
        }else if(value=="3"){
            return [
                '<span style="text-align: center;display:block;"><label class="label label-success label-block" style="cursor:pointer">放弃执行</label></span>', ]
                .join('');
        }
    }

    var operateFormatterTime = function(value,row,index) {//赋予的参数
        var dateee = new Date(value).toJSON();
        var date = new Date(+new Date(dateee)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'')
        return date;
    }

    var operateFormatterStatus1 = function(value,row,index) {//赋予的参数
        if (value=="0") {
            return [
                '<span style="text-align: center;display:block;"><label class="label label-success label-block" style="cursor:pointer">已启动</label></span>', ]
                .join('');
        }else if(value=="1"){
            return [
                '<span style="text-align: center;display:block;"><label class="label label-primary label-block" style="cursor:pointer">暂停</label></span>', ]
                .join('');
        }
    }







   ajax.postData(publicData.urls.system.getFields, {'tableName':myTableName}, function (data) {
       var html='<th data-field="state" data-checkBox="true">#</th>';
       html+='<th data-field="rowNum" data-align="left" data-halign="left" data-valign="middle" data-formatter="bootstrapFormatter.rowNumFormatter">序号</th>'

       for(var i = 0;i < data.length;++i){
           var codeAndInfo = data[i];
           if(codeAndInfo.column_name == "id"||codeAndInfo.column_name =="cron_expression"){

           }else if(codeAndInfo.column_name == "misfire_policy"){
               html+='<th data-field="'+codeAndInfo.column_name+'" data-align="left" data-halign="left"'
                   +'data-valign="middle" data-sortable="true" data-formatter="operateFormatterStatus">'+codeAndInfo.column_comment+'</th>';
           }else if(codeAndInfo.column_name == "create_time"||codeAndInfo.column_name == "update_time"){
               html+='<th data-field="'+codeAndInfo.column_name+'" data-align="left" data-halign="left"'
                   +'data-valign="middle" data-sortable="true" data-formatter="operateFormatterTime">'+codeAndInfo.column_comment+'</th>';
           }else if(codeAndInfo.column_name == "status"){
               html+='<th data-field="'+codeAndInfo.column_name+'" data-align="left" data-halign="left"'
                   +'data-valign="middle" data-sortable="true" data-formatter="operateFormatterStatus1">'+codeAndInfo.column_comment+'</th>';
           }else{
               html+='<th data-field="'+codeAndInfo.column_name+'" data-align="left" data-halign="left"'
                   +'data-valign="middle" data-sortable="true">'+codeAndInfo.column_comment+'</th>';
           }
       }
       $("#tab").html(html);
       if ( data!=null||data!="") {
           $("#data-table").bootstrapTable("refresh");
           $("#data-table").bootstrapTable({url: publicData.urls.system.getPage});
       }else{
           $("#tab").html("不存在");
       }
   });
   var bootStrap={}
   //这个携带页面查询参数
    function getParam(params) {
        var total=commonTools.getBootstrapParams(params, $("#form-search"))
        total.params.tableName=myTableName;
        if(total.sort==undefined){
            total.sort='update_time';
            total.order='desc';
        }
        bootStrap=total;
        return total;
    }

    $("#btn-search").click(function () {
        $("#data-table").bootstrapTable("refresh");
    });




    $("#btn-add").click(function () {
        commonTools.setFormData({}, $("#form-input"));
        $("#time").val("点我选择时间")
        //========表达式选择模块 h 时分，m分，hm时，分单选
/*        $('#time').jHsDate({
            format:'h',
            inputIsRead: true
        });*/
        //========表达式选择模块结束
        var $radio=$('input[name="Storage"]')
        for(var i=0;i<$radio.length;i++){
            if($($radio[i]).attr("id")=="model1"){
                $($radio[i]).click();
            }
        }
        var labelid=$('input[name="Storage"]:checked').attr("id")
        var cornType=$("#"+labelid+"label").text();
         $("#time").unbind();
        if(cornType=="每天执行"){
            $('#labelMessage').html("每天")
            $('#time').jHsDate({
                format:'hh',
                inputIsRead: true
            });
        }else if(cornType=="间隔执行"){
            $('#labelMessage').html("间隔")
            $('#time').jHsDate({
                format:'hm',
                inputIsRead: true
            });
        }
        //$('input[name="Storage"]').val("0");
        $("#input-modal").attr("data-save-type", "add");
        $("#input-modal").modal("show");
    });

    $("#btn-edt").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        if (datas.length == 0) {
            messageBox.info("请选择要修改的数据");
            return;
        }
        if (datas.length > 1) {
            messageBox.info("只能同时修改一条数据");
            return;
        }
        commonTools.setFormData(datas[0], $("#form-input"));
        $("#input-modal").attr("data-save-type", "edt");
        $("#input-modal").modal("show");
    });

    //当执行方式改变时同时改变时间的选择方式同时移除所有事件并初始化
    $('input[type=radio][name=Storage]').change(function() {
        var labelid=$('input[name="Storage"]:checked').attr("id")
        var cornType=$("#"+labelid+"label").text();
        $("#time").unbind();
        if(cornType=="每天执行"){
            $('#labelMessage').html("每天")
            $('#time').jHsDate({
                format:'hh',
                inputIsRead: true
            });
        }else if(cornType=="间隔执行"){
            $('#labelMessage').html("间隔")
            $('#time').jHsDate({
                format:'hm',
                inputIsRead: true
            });
        }
    })
    $("#btn-save").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        var saveType = $("#input-modal").attr("data-save-type");
        var saveData = $("#form-input").serializeObject();
        if(saveData.job_name==""){
            messageBox.info("请选择定时任务所在类");
            return;
        }else if(saveData.job_group==""){
            messageBox.info("请选择定时任务参数类型");
            return;
        }else if(saveData.method_name==""){
            messageBox.info("请选择定时任务方法名称");
            return;
        }else if(saveData.jHsDateInput=="点我选择时间"){
            messageBox.info("请选择定时任务执行时间");
            return;
        }else if(saveData.misfirePolicy==""){
            messageBox.info("请选择任务失败时的策略");
            return;
        }
        //得到真正的corn表达式
        var labelid=$('input[name="Storage"]:checked').attr("id")
        var cornType=$("#"+labelid+"label").text();
        var cornStr=saveData.jHsDateInput;
        var cron="";
        var cron_cn="";
        if(cornType=="每天执行"){
            var hourStr=cornStr.split('时')[0];
            var hourStrO=cornStr.split('时')[1];
            var minStr=hourStrO.split('分')[0];
            cron="0 "+minStr+" "+hourStr+" * * ?";
            cron_cn="每天的 "+hourStr+"时"+minStr+"分 执行一次"
        }else{
            if(cornStr.indexOf("时")>-1){
                var hourStr=cornStr.split('小时')[0];
                cron="0 0 0/"+hourStr+" * * ?";
                cron_cn="每隔 "+hourStr+"小时 执行一次";
            }else{
                var minStr=cornStr.split('分钟')[0];
                cron="0 0/"+minStr+" * * * ?";
                cron_cn="每隔 "+minStr+"分钟 执行一次";
            }
        }
        saveData.cronExpression=cron
        saveData.cron_cn=cron_cn
        if(saveData.jobGroup=="1"){
            saveData.jobGroup="有参数";
        }
        if(saveData.jobGroup=="2"){
            saveData.jobGroup="无参数";
        }
        if(saveType=='edt'){
            //ajax.postData(publicData.urls.system.addOrEdt,{'message':JSON.stringify(message)}, function (data) {
                //$("#input-modal").modal("hide");
                $("#data-table").bootstrapTable("refresh");
           // });
        }else{
            ajax.postData(publicData.urls.schedule.addJob,saveData, function (data) {
                if(data==""){
                    messageBox.success("添加定时任务成功");
                    $("#input-modal").modal("hide");
                    $("#data-table").bootstrapTable("refresh");
                }else{
                    messageBox.error(data);
                    $("#input-modal").modal("hide");
                    $("#data-table").bootstrapTable("refresh");
                }

            });

        }

    });

    $("#btn-del").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        if (datas.length == 0) {
            messageBox.info("请选择要删除的数据");
            return;
        }
        var ids="";
        for(var i=0;i<datas.length;i++){
            ids+=datas[i].id
            if(i==datas.length-1){

            }else{
                ids+=",";
            }
        }
        messageBox.confirm("您确认要删除该数据吗？", function(){
            ajax.postData(publicData.urls.schedule.remove, {"ids": ids}, function () {
                messageBox.success("删除成功");
                $("#data-table").bootstrapTable("refresh");
            });
        }, undefined);
    });

    $("#btn-pause").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        if (datas.length == 0) {
            messageBox.info("请选择要暂停的任务");
            return;
        }
        var ids="";
        for(var i=0;i<datas.length;i++){
            ids+=datas[i].id
            if(i==datas.length-1){

            }else{
                ids+=",";
            }
        }

        messageBox.confirm("您确认要启动选择的任务吗？", function(){
            ajax.postData(publicData.urls.schedule.pauseJob, {"ids": ids}, function (data) {
                if(data!=""){
                    messageBox.success("成功暂停"+data+"个任务");
                    $("#data-table").bootstrapTable("refresh");
                }else{
                    messageBox.error("暂停任务出错");
                    $("#data-table").bootstrapTable("refresh");
                }
            });
        }, undefined);

    });

    $("#btn-start").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        if (datas.length == 0) {
            messageBox.info("请选择要启动的任务");
            return;
        }
        var ids="";
        for(var i=0;i<datas.length;i++){
            ids+=datas[i].id
            if(i==datas.length-1){

            }else{
                ids+=",";
            }
        }

        messageBox.confirm("您确认要启动选择的任务吗？", function(){
            ajax.postData(publicData.urls.schedule.resumeJob, {"ids": ids}, function (data) {
                if(data!=""){
                    messageBox.success("成功启动"+data+"个任务");
                    $("#data-table").bootstrapTable("refresh");
                }else{
                    messageBox.error("启动任务出错");
                    $("#data-table").bootstrapTable("refresh");
                }
            });
        }, undefined);
    });

    $("#btn-startNow").click(function () {
        var datas = $("#data-table").bootstrapTable("getSelections");
        if (datas.length == 0) {
            messageBox.info("请选择要立即执行的任务");
            return;
        }
        if (datas.length > 1) {
            messageBox.info("同时只能选择一个任务立即执行");
            return;
        }
        var id=datas[0].id
        messageBox.confirm("您确认要立即执行该任务吗？", function(){
            ajax.postData(publicData.urls.schedule.jobStartNow, {"id": id}, function (data) {
                if(data==""){
                    messageBox.success("任务已经立即执行");
                }else{
                    messageBox.error("任务执行出错");
                }
            });
        }, undefined);
    });









    //==============导出模块

   $("#btn-export").click(function () {
       $("#checks").html("");
       ajax.postData(publicData.urls.system.getFields, {'tableName':myTableName}, function (data) {
           var bb="";
           for(var i = 0;i < data.length;++i){
               var codeAndInfo = data[i];
               bb+="<label class='btn btn-default' style='width: 80%;margin-bottom: 5px;margin-left: 10%;margin-right: 10%;'>"
                   +"<input  name='columnCheckBoxs'    value='"+codeAndInfo.column_name+"' type='checkbox'>"+codeAndInfo.column_comment
                   +"</label>"
           }
           $("#checks").html(bb);
       })
      $("#input-modal2").modal("show");
   })

   $("#btn-save2").click(function () {
       var obj = document.getElementsByName("columnCheckBoxs");
       var check_val =[];
       var columnStr="";
       for(var k in obj){
           if(obj[k].checked)
               columnStr+=obj[k].value+",";
       }
       columnStr=columnStr.substring(0,columnStr.length-1)
       bootStrap.columnStr=columnStr;
       var message=JSON.stringify(bootStrap);
       message=message.replace(/\{/g,"(")
       message= message.replace(/\}/g,")")
       window.location.href=publicData.urls.system.exportMessage+"?message="+message
       $("#input-modal2").modal("hide");
       messageBox.success("导出成功");

   })

   $("#btn-selectAll").click(function () {
       $("#checks .btn").button('toggle')
   })




</script>
</body>
</html>